package com.tenton.service.Impl;

import com.tenton.mapper.ProvinceMapper;
import com.tenton.pojo.Province;
import com.tenton.service.ProvinceService;
import com.tenton.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @Date: 2021/1/14
 * @Author: Tenton
 * @Description:
 */
public class ProvinceServiceImpl implements ProvinceService {
    /**
     * 查询所有省份
     * @return
     */
    @Override
    public List<Province> listProvince() {
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        ProvinceMapper mapper = sqlSession.getMapper(ProvinceMapper.class);
        List<Province> provinces = mapper.listProvince();
        return provinces;
    }

    @Override
    public Province getProvince(String name) {
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        ProvinceMapper mapper = sqlSession.getMapper(ProvinceMapper.class);
        Province province = mapper.getProvince(name);
        return province;
    }
}
